/*
 * ouwen@yiji.com Inc.
 * Copyright (c) 2017 All Rights Reserved.
 * create by ouwen
 * date:2017-03-30
 *
 */
package com.acooly.module.openapi.client.provider.jyt.enums;

import com.acooly.core.utils.Strings;
import com.acooly.core.utils.enums.Messageable;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * inst_channel_api DebitCreditType 枚举定义
 *
 * @author zhike
 * Date: 2017-03-30 15:12:06
 */
public enum JytRespCodeEnum implements Messageable {

    S0000000("S0000000","处理成功"),
    ERN00000("ERN00000","数据库数据异常"),
    ERN00001("ERN00001","首次绑卡失败-商户下用户卡信息已绑定"),
    ERN00002("ERN00002","身份证号码错误"),
    ERN00003("ERN00003","手机号码错误"),
    ERN00004("ERN00004","商户未开通实名支付业务"),
    ERN00005("ERN00005","商户未绑定虚拟账户"),
    ERN00006("ERN00006","订单不存在"),
    ERN00007("ERN00007","订单已支付"),
    ERN00008("ERN00008","订单已失败"),
    ERN00009("ERN00009","未知订单状态"),
    ERN00010("ERN00010","商户下未绑定用户卡信息"),
    ERN00011("ERN00011","卡状态错误"),
    ERN00012("ERN00012","用户预留手机号与鉴权手机号不一致"),
    ERN00013("ERN00013","暂不支持其他充值方式"),
    ERN00014("ERN00014","渠道支付失败"),
    ERN00015("ERN00015","银行四要素验证失败"),
    ERN00016("ERN00016","本平台四要素验证失败"),
    ERN00017("ERN00017","二次支付-用户未绑卡或卡状态错误"),
    ERN00018("ERN00018","流水号不可用"),
    ERN00019("ERN00019","订单时间异常，不接受半小时前的商户请"),
    ERN00020("ERN00020","支付状态异常，银行查账结果仍为进行中"),
    ERN00021("ERN00021","支付状态异常，银行查账结果不是成功/失败/进行中"),
    ERN00022("ERN00022","金额必须大于0.01"),
    ERN00023("ERN00023","首次绑卡失败-商户下客户状态不可用"),
    ERN00024("ERN00024","该卡已经解卡成功，不可再做解卡操作"),
    ERN00025("ERN00025","银行卡绑卡成功，首次交易失败"),
    ERN00026("ERN00026","一张卡只能被一个客户绑定"),
    ERN00027("ERN00027","客户绑定银行卡数量已超过最大限制"),
    ERN00028("ERN00028","该银行卡未绑定"),
    ERN00029("ERN00029","支付鉴权码与订单号不匹配"),
    ERN00030("ERN00030","CVV2为空"),
    ERN00031("ERN00031","信用卡有效期为空"),
    ERN00032("ERN00032","银行卡类型不合法"),
    ERN00033("ERN00033","该卡号不是借记卡"),
    ERN00034("ERN00034","该卡号不是信用卡"),
    ERN00035("ERN00035","暂不支持该信用卡"),
    ERN00036("ERN00036","请求用户信息与平台客户信息不一致"),
    ERN00037("ERN00037","用户放弃支付该笔交易"),
    ERN00038("ERN00038","渠道解除绑定异常"),
    ERN00039("ERN00039","没有开通信用卡功能"),
    ERN00040("ERN00040","实名支付渠道路由不存在"),
    ERN00041("ERN00041","支付下单的手机号与绑定的手机号不一致"),
    ERN00042("ERN00042","支付的客户号与绑定的客户号不一致"),

    EB000013("EB000013","50秒内重复请求短信"),
    E0000008("E0000008","格式化短信内容失败"),
    EB000014("EB000014","验证码不存在"),
    EB000015("EB000015","短信验证码已超时失效"),
    EB000016("EB000016","短信验证码输入错误"),
    E0000003("E0000003","验证码长度错误或验证码不能为空"),

    ER000011("ER000011","银行卡号为空或长度不正确"),
    ER000013("ER000013","身份证号为空或者不合法"),
    ER000014("ER000014","姓名为空或者长度太长"),
    ER000024("ER000024","查找验证交易路由失败，请联系管理员"),
    ER000025("ER000025","验证失败,用户提交信息不合法或验证超时"),
    ER000026("ER000026","此认证渠道不支持该证件类型认证"),
    ER000027("ER000027","此卡未开通银联在线支付功能,实名认证失败"),
    ER001001("ER001001","该银行卡bin不支持"),
    ER001004("ER001004","不支持此银行卡的验证"),
    ER001005("ER001005","银行卡类型不符"),
    ER001006("ER001006","上送的银行卡号与银行编号不符"),
    ER999999("ER999999","银行认证系统异常"),

    E0000000("E0000000","处理中"),
    E0000032("E0000032","交易金额为空"),
    E0000033("E0000033","金额格式有误"),
    E0000034("E0000034","交易日期为空"),
    E0000035("E0000035","银行账号不能为空"),
    E0000036("E0000036","银行户名不能为空"),
    E0000050("E0000050","黑名单用户"),
    E7000002("E7000002","交易金额超出单笔限额，拒绝交易"),
    E7000003("E7000003","交易金额超出单日限额，拒绝交易"),
    E7000004("E7000004","交易金额超出单月限额，拒绝交易"),
    E7000011("E7000011","运营审核拒绝"),
    E8000001("E8000001","平台交易记录不存在"),
    E8000002("E8000002","渠道交易记录不存在"),
    E8000003("E8000003","交易流水号重复"),
    E8000006("E8000006","记录信息不存在"),
    E9000001("E9000001","系统忙，请稍后再提交"),
    E9000002("E9000002","未定义的错误码"),
    E9999998("E9999998","未知错误"),
    E9999999("E9999999","系统错误"),
    EB000001("EB000001","未找到匹配支付渠道路由"),
    EB000002("EB000002","该支付渠道路由已存在"),
    EB000003("EB000003","该支付渠道路由起始金额或时间设置与已有渠道重叠"),
    EB000004("EB000004","支付渠道被禁用"),
    EB000005("EB000005","支付渠道未实现，不支持交易"),
    EB000006("EB000006","支付渠道代码无效"),
    EB000008("EB000008","无效的白名单记录"),
    EB000009("EB000009","银行联行号不正确"),
    EB000010("EB000010","银行联行号格式无效"),
    EB000011("EB000011","银行代码无效"),
    EX000001("EX000001","未开通无卡支付或交易超过限额，详情请咨询您的发卡行"),
    EX000002("EX000002","交易查询失败"),
    EX000003("EX000003","查开户方原因"),
    EX000004("EX000004","银行卡号无效"),
    EX000005("EX000005","银行存折已挂失"),
    EX000006("EX000006","交易金额有误错误"),
    EX000007("EX000007","银行账户余额不足"),
    EX000008("EX000008","银行卡已挂失"),
    EX000009("EX000009","银行账户不存在"),
    EX000010("EX000010","银行卡已过有效期"),
    EX000011("EX000011","银行交易超过限额"),
    EX000012("EX000012","超出单卡号累计交易次数限制"),
    EX000013("EX000013","原交易已被渠道取消或冲正"),
    EX000015("EX000015","交易货币不支持"),
    EX000016("EX000016","银行账号为非通兑户"),
    EX000017("EX000017","银行账号已关闭"),
    EX000018("EX000018","银行卡未开通银联在线支付，请向银行或95516咨询"),
    EX000019("EX000019","银行卡已被锁定"),
    EX000020("EX000020","交易失败，详情请咨询您的发卡行"),
    EX000021("EX000021","持卡人身份证验证失败"),
    EX000022("EX000022","交易失败，风险受限"),
    EX000023("EX000023","渠道交易验签不成功"),
    EX000024("EX000024","渠道交易处理失败"),
    EX000025("EX000025","交易时间跨天，引起时间不合法"),
    EX000026("EX000026","持卡人证件类型不支持"),
    EX000027("EX000027","渠道不支持该银行的交易"),
    EX000028("EX000028","交易金额不能低于最小限额"),
    EX000029("EX000029","交易金额不能大于最大限额"),
    EX000030("EX000030","发卡行不予承兑"),
    EX000031("EX000031","证件类型与卡号不符"),
    EX000032("EX000032","证件号错误，请核实"),
    EX000035("EX000035","交易金额超过渠道当月限额"),
    EX000037("EX000037","平台商户号在渠道的用户名或密码错误"),
    EX000038("EX000038","平台商户号在渠道的银行户名有误"),
    EX000039("EX000039","平台商户号在渠道系统不存在"),
    EX000040("EX000040","超出银行授信额度"),
    EX000041("EX000041","平台银行账户不允许交易"),
    EX000042("EX000042","平台银行账户扣款失败"),
    EX000043("EX000043","平台银行账户未在银行端签约"),
    EX000044("EX000044","银行账号不在渠道白名单列表中，交易失败"),
    EX000045("EX000045","银行账号、户名、证件信息不匹配"),
    EX000046("EX000046","卡已销毁或撤销"),
    EX000049("EX000049","渠道交易业务尚未开通"),
    EX000050("EX000050","用户信息实名认证未通过，交易失败"),
    EX000051("EX000051","超过用户在银行设置的限额"),
    EX000052("EX000052","非工作时间，银行交易拒绝"),
    EX000053("EX000053","渠道绑卡ID不匹配"),
    EX000054("EX000054","渠道签约失败"),
    EX000055("EX000055","用户此卡号已签约"),
    EX000056("EX000056","该卡已过有效期"),
    EX000057("EX000057","CVN错误"),
    EX000058("EX000058","渠道解绑卡失败"),
    EX000059("EX000059","银行支付校验码输入错误"),
    EX000060("EX000060","银行支付校验码失效"),
    EX000061("EX000061","退货退款失败"),
    EX000062("EX000062","渠道订单已失效"),
    EX000063("EX000063","渠道绑卡已过期"),
    EX900001("EX900001","渠道交易订单号重复"),
    EX999990("EX999990","渠道支付通道无路由或关闭"),
    EX999991("EX999991","渠道报文有必填项为空"),
    EX999992("EX999992","渠道报文解析错误"),
    EX999994("EX999994","渠道系统正在日终处理"),
    EX999995("EX999995","渠道系统处理失败"),
    EX999996("EX999996","支付通道不支持该笔交易"),
    EX999997("EX999997","渠道直接置交易失败"),
    EX999998("EX999998","银行系统繁忙，交易失败，请稍后再提交"),
    EX999999("EX999999","渠道返回其他错误"),

    EF000001("EF000001","手续费规则不存在"),
    EF000002("EF000002","手续费规则设置的不正确"),
    EF000003("EF000003","手续费规则未启用"),
    EF000004("EF000004","手续费账户不存在"),
    EF000005("EF000005","账户余额不足"),
    EF000006("EF000006","交易金额小于最小值（手续费）"),
    EF000007("EF000007","手续费费率不存在"),
    EF000008("EF000008","单一费率记录不存在（规则配置有误）"),
    EF000009("EF000009","阶梯费率记录不存在（规则配置有误）"),
    EF000010("EF000010","操作有效时间有误"),
    EF000011("EF000011","付款账户与手续费账户账户相同"),





            ;

    private final String code;
    private final String message;

    private JytRespCodeEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public boolean getSmsRespCode() {
        if (Strings.equals(code,EB000013.getCode())||
                Strings.equals(code,E0000008.getCode())||
                Strings.equals(code,EB000014.getCode())||
                Strings.equals(code,EB000015.getCode())||
                Strings.equals(code,EB000016.getCode())||
                Strings.equals(code,E0000003.getCode())) {
            return true;
        } else {
            return false;
        }
    }

    public  boolean payUnknownRespCode() {
        if (Strings.equals(code,ERN00000.getCode())||
                Strings.equals(code,ERN00007.getCode())||
                Strings.equals(code,ERN00009.getCode())) {
            return true;
        } else {
            return false;
        }
    }
    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public String code() {
        return code;
    }

    public String message() {
        return message;
    }

    public static Map<String, String> mapping() {
        Map<String, String> map = new LinkedHashMap<String, String>();
        for (JytRespCodeEnum type : values()) {
            map.put(type.getCode(), type.getMessage());
        }
        return map;
    }

    /**
     * 通过枚举值码查找枚举值。
     *
     * @param code 查找枚举值的枚举值码。
     * @return 枚举值码对应的枚举值。
     * @throws IllegalArgumentException 如果 code 没有对应的 Status 。
     */
    public static JytRespCodeEnum find(String code) {
        for (JytRespCodeEnum status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }

    /**
     * 获取全部枚举值。
     *
     * @return 全部枚举值。
     */
    public static List<JytRespCodeEnum> getAll() {
        List<JytRespCodeEnum> list = new ArrayList<JytRespCodeEnum>();
        for (JytRespCodeEnum status : values()) {
            list.add(status);
        }
        return list;
    }

    /**
     * 获取全部枚举值码。
     *
     * @return 全部枚举值码。
     */
    public static List<String> getAllCode() {
        List<String> list = new ArrayList<String>();
        for (JytRespCodeEnum status : values()) {
            list.add(status.code());
        }
        return list;
    }

}
